﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.membercenter.order
{
    public partial class order_feedback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                InitWebControl();
                string orderId = ChangeHope.WebPage.PageRequest.GetQueryString("id");
                if(orderId!=""&&orderId!=null){
                    ViewState["orderId"] = orderId;
                    this.lblName.Text = Session["MemberName"].ToString();
                    this.lblTime.Text = System.DateTime.Now.ToString();
                }
               
            }
        }

        #region 验证
        private void InitWebControl()
        {
            ChangeHope.WebPage.WebControl.Validate(this.txtContent,"反馈信息不能为空","isnull","必填","该项为必填项");
            this.Form.Attributes.Add("onsubmit", "return CheckForm()");
        }
        #endregion

        //确定
        protected void linkOk_Click(object sender, EventArgs e)
        {
            YXShop.BLL.Order.OrderLeave leaveBll = new YXShop.BLL.Order.OrderLeave();
            YXShop.Model.Order.OrderLeave model = new YXShop.Model.Order.OrderLeave();
            YXShop.BLL.Order.Orders orderBll = new YXShop.BLL.Order.Orders();
            YXShop.Model.Order.Orders orderModel = orderBll.GetModel(Convert.ToInt32(ViewState["orderId"]));
            model.MemberId = Convert.ToInt32(Session["MemberID"].ToString());
            if(orderModel!=null)
            {
                model.OrderId = orderModel.OrderId;
            }         
            model.State = 1;
            model.Content = this.txtContent.Text.Trim().ToString();
            model.CreateDate = Convert.ToDateTime(System.DateTime.Now);
            int count = leaveBll.Add(model);
            if (count > 0)
            {
                this.ltlMsg.Text = "操作成功，已反馈该信息";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionOk";
            }
            else
            {
                this.ltlMsg.Text = "操作失败!";
                this.pnlMsg.Visible = true;
                this.pnlMsg.CssClass = "actionErr";
            }
        }
    }
}
